package py.com.erpone.entity.dm;

import java.io.Serializable;
import java.util.List;


import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;

import javax.validation.constraints.NotNull;


@Entity
@NamedQueries(value = {
		@NamedQuery(name = "rol.all", query = "select r from Rol r order by r.descripcion"), 
		})
public class Rol implements Serializable{
	
	
	private static final long serialVersionUID = 1L;

	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;

	@NotNull
	private String descripcion;

	//@OneToMany // (mappedBy = "rol",cascade=CascadeType.ALL,orphanRemoval=true)
	@ManyToMany
	@JoinTable(name = "Rol_Tarea")
	private List<Tarea> tarea;
	
	public Rol() {
		super();
		
	}
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	public Rol(String descripcion) {
		super();
		this.descripcion = descripcion;
	}

	public String getDescripcion() {
		return this.descripcion;
	}

	public void setDescripcion(String descripcion) {
		this.descripcion = descripcion;
	}
	

	public List<Tarea> getTarea() {
		return tarea;
	}
	public void setTarea(List<Tarea> tarea) {
		this.tarea = tarea;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((descripcion == null) ? 0 : descripcion.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Rol other = (Rol) obj;
		if (descripcion == null) {
			if (other.descripcion != null)
				return false;
		} else if (!descripcion.equals(other.descripcion))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Rol [descripcion=" + descripcion + "]";
	}
	
	
}
